package com.pospi.xstore.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.pospi.xstore.R;
import com.pospi.xstore.dto.StoreMsgDto;

import java.util.List;


/**
 * Created by Qiyan on 2016/4/13.
 */
public class StoreSelectionAdapter extends BaseAdapter {

    private List<StoreMsgDto> msgDtos;
    private Context context;

    public StoreSelectionAdapter(List<StoreMsgDto> msgDtos, Context context) {
        this.msgDtos = msgDtos;
        this.context = context;
    }

    @Override
    public int getCount() {
        return msgDtos.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public Object getItem(int position) {
        return msgDtos.get(position);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.storeselection_item, null);
        TextView tv = (TextView) convertView.findViewById(R.id.item_tv);
        tv.setText(msgDtos.get(position).getName());
        return convertView;
    }
}
